//
//  CYBaseTableViewController.swift
//  CYSinaWB
//
//  Created by mac on 16/2/16.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CYBaseTableViewController: UITableViewController,VistorLoginViewDelegate {
    
    //判断是否登录
//    var userLogin  = CYUserAccount.loadUserInfo()?.access_token != nil
    var userLogin = CYAccountViewModel.sharedViewModel.userLogin
    //访客视图的属性
    var visitorLoginView: CYVistorLoginView?
    
    override func loadView() {
        if userLogin {
            super.loadView()
        } else {
            visitorLoginView = CYVistorLoginView()
            visitorLoginView?.visitorLoginViewDelegate = self
            view = visitorLoginView
            
            navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
            navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
        }
    }
    
    func userWillLogin() {
        print(__FUNCTION__)
        let oauth = CYOAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    func userWillRegister() {
        print(__FUNCTION__)
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    
}
